//
//  Fc3dNumber.m
//  PlayBall
//
//  Created by Sun Fanglei on 13-3-19.
//
//

#import "JddFc3dNumber.h"

@implementation JddFc3dNumber

@synthesize BallArray;
@synthesize SecondBallArray;
@synthesize ThirdBallArray;
@synthesize FourthBallArray;
@synthesize FifthBallArray;
@synthesize SixthBallArray;
@synthesize SeventhBallArray;

-(id)init{
    self = [super init];
    if (self) {
        self.BallArray = [NSMutableArray array];
        self.SecondBallArray = [NSMutableArray array];
        self.ThirdBallArray = [NSMutableArray array];
        self.FourthBallArray = [NSMutableArray array];
        self.FifthBallArray = [NSMutableArray array];
        self.SixthBallArray = [NSMutableArray array];
        self.SeventhBallArray = [NSMutableArray array];
    }
    return self;
}

-(NSInteger)addBallNumber:(NSInteger)number{
    [BallArray addObject:[NSNumber numberWithInteger:number]];
    return [BallArray count];
}

-(NSInteger)removeBallNumber:(NSInteger)number{
    for (NSNumber *ns in BallArray) {
        if ([ns intValue] == number) {
            [BallArray removeObject:ns];
            break;
        }
    }
    return [BallArray count];
}

-(NSInteger)add2BallNumber:(NSInteger)number{
    [SecondBallArray addObject:[NSNumber numberWithInteger:number]];
    return [SecondBallArray count];
}

-(NSInteger)remove2BallNumber:(NSInteger)number{
    for (NSNumber *inNum in SecondBallArray) {
        if ([inNum intValue] == number) {
            [SecondBallArray removeObject:inNum];
            break;
        }
    }
    return  [SecondBallArray count];
}

-(NSInteger)add3BallNumber:(NSInteger)number{
    [ThirdBallArray addObject:[NSNumber numberWithInteger:number]];
    return [ThirdBallArray count];
}

-(NSInteger)remove3BallNumber:(NSInteger)number{
    for (NSNumber *inNum in ThirdBallArray) {
        if ([inNum intValue] == number) {
            [ThirdBallArray removeObject:inNum];
            break;
        }
    }
    return [ThirdBallArray count];
}

-(NSInteger)add4BallNumber:(NSInteger)number{
    [FourthBallArray addObject:[NSNumber numberWithInteger:number]];
    return [FourthBallArray count];
}

-(NSInteger)remove4BallNumber:(NSInteger)number{
    for (NSNumber *inNum in FourthBallArray) {
        if ([inNum intValue] == number) {
            [FourthBallArray removeObject:inNum];
            break;
        }
    }
    return [FourthBallArray count];
}

-(NSInteger)add5BallNumber:(NSInteger)number{
    [FifthBallArray addObject:[NSNumber numberWithInteger:number]];
    return [FifthBallArray count];
}

-(NSInteger)remove5BallNumber:(NSInteger)number{
    for (NSNumber *inNum in FifthBallArray) {
        if ([inNum intValue] == number) {
            [FifthBallArray removeObject:inNum];
            break;
        }
    }
    return [FifthBallArray count];
}

-(NSInteger)add6BallNumber:(NSInteger)number{
    [SixthBallArray addObject:[NSNumber numberWithInteger:number]];
    return [SixthBallArray count];
}

-(NSInteger)remove6BallNumber:(NSInteger)number{
    for (NSNumber *inNum in SixthBallArray) {
        if ([inNum intValue] == number) {
            [SixthBallArray removeObject:inNum];
            break;
        }
    }
    return [SixthBallArray count];
}

-(NSInteger)add7BallNumber:(NSInteger)number{
    [SeventhBallArray addObject:[NSNumber numberWithInteger:number]];
    return [SeventhBallArray count];
}

-(NSInteger)remove7BallNumber:(NSInteger)number{
    for (NSNumber *inNum in SeventhBallArray) {
        if ([inNum intValue] == number) {
            [SeventhBallArray removeObject:inNum];
            break;
        }
    }
    return [SeventhBallArray count];
}

-(void)clear{
    [BallArray removeAllObjects];
    [SecondBallArray removeAllObjects];
    [ThirdBallArray removeAllObjects];
    [FourthBallArray removeAllObjects];
    [FifthBallArray removeAllObjects];
    [SixthBallArray removeAllObjects];
    [SeventhBallArray removeAllObjects];
}

-(BOOL)BallHasNumber:(NSInteger)number{
    for (NSNumber *inNum in BallArray) {
        if ([inNum intValue] == number) {
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball2HasNumber:(NSInteger)number{
    for (NSNumber *inNum in SecondBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball3HasNumber:(NSInteger)number{
    for (NSNumber *inNum in ThirdBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball4HasNumber:(NSInteger)number{
    for (NSNumber *inNum in FourthBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball5HasNumber:(NSInteger)number{
    for (NSNumber *inNum in FifthBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball6HasNumber:(NSInteger)number{
    for (NSNumber *inNum in SixthBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(BOOL)Ball7HasNumber:(NSInteger)number{
    for (NSNumber *inNum in SeventhBallArray) {
        if([inNum intValue] == number){
            return YES;
        }
    }
    return NO;
}

-(NSString *)ballNum{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in BallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball2Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in SecondBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball3Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in ThirdBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball4Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in FourthBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball5Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in FifthBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball6Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in SixthBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)ball7Num{
    NSMutableString *res = [NSMutableString string];
    for (NSNumber *inNum in SeventhBallArray) {
        [res appendFormat:@"%d",[inNum intValue]];
    }
    return res;
}

-(NSString *)print{
    NSString* res = @"1ball";
    for (NSNumber *inNum in BallArray) {
        res = [NSString stringWithFormat:@"%@-%d",res,[inNum intValue]];
    }
    res = [NSString stringWithFormat:@"%@|%@",res,@"2ball"];
    for (NSNumber *inNum in SecondBallArray) {
        res = [NSString stringWithFormat:@"%@-%d",res,[inNum intValue]];
    }
    res = [NSString stringWithFormat:@"%@|%@",res,@"3ball"];
    for (NSNumber *inNum in ThirdBallArray) {
        res = [NSString stringWithFormat:@"%@-%d",res,[inNum intValue]];
    }
    
    return res;
}

@end
